package View.JTable;

import java.awt.Component;

import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import View.CoolSwing.CoolButton;

public class MyTableButtonCellRenderer extends CoolButton implements TableCellRenderer {
	private String stringValue = null;

    protected boolean selected = false;

    protected boolean hasFocus = false;
	
    /**
     * 构造方法
     */
	public MyTableButtonCellRenderer() {
		super();
	}

	/**
	 * TreeCellRenderer的方法被重写，
	 * 被JAnimatorTree调用获得CoolButton来绘制树的单元
	 */

	@Override
	public Component getTableCellRendererComponent(JTable table,
										            Object value,
										            boolean isSelected,
										            boolean hasFocus,
										            int row,
										            int column) {
		if(value instanceof String) {
			this.stringValue = (String)value;
			setText(stringValue);
		}

		setText(stringValue);
		if(value instanceof JButton) {
			return (JButton)value;
		}
		return this;
	}

}
